package com.hnkywl.sts.util;

import com.hnkywl.sts.service.cwgl.CwsfService;
import com.hnkywl.sts.service.flow.FlowService;
import com.hnkywl.sts.service.htgl.CghtService;
import com.hnkywl.sts.service.htgl.XshtService;
import com.hnkywl.sts.service.jhgl.JkdService;
import com.hnkywl.sts.service.jhgl.WzjhService;
import com.hnkywl.sts.service.jhgl.XyService;
import com.hnkywl.sts.service.jhgl.ZjjhService;
import com.hnkywl.sts.service.jsgl.ZjbcdService;
import com.hnkywl.sts.service.organ.GsjgService;
import com.hnkywl.sts.service.organ.LjLsService;
import com.hnkywl.sts.service.organ.LjwhService;
import com.hnkywl.sts.service.organ.QyjgService;
import com.hnkywl.sts.service.sfgl.FkshService;
import com.hnkywl.sts.service.sfgl.SkshService;
import com.hnkywl.sts.service.sfgl.TpfkService;
import com.hnkywl.sts.service.sys.YgService;
import com.hnkywl.sts.service.taskdeal.DoBgcgdSync;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: jerry
 * Date: 13-5-10
 * Time: 上午9:40
 * To change this template use File | Settings | File Templates.
 */
public class ApplicationInstance implements ApplicationContextAware {
    private static ApplicationContext ac;

    private static FlowService flowService;

    private static YgService ygService;

    private static GsjgService gsjgService;

    private static XyService xyService;

    private static CghtService cghtService;

    private static XshtService xshtService;

    private static WzjhService wzjhService;

    private static ZjjhService zjjhService;

    private static JkdService jkdService;

    private static LjwhService ljwhService;

    private static QyjgService qyjgService;

    private static LjLsService ljLsService;

    private static FkshService fkshService;

    private static TpfkService tpfkService;

    private static ZjbcdService zjbcdService;

    private static DoBgcgdSync doBgcgdSync;

    public static FlowService createFlowService() {
        if (flowService == null)
            flowService = (FlowService) getAc().getBean("flowService");
        return flowService;
    }

    public static YgService createYgService() {
        if (ygService == null)
            ygService = (YgService) getAc().getBean("ygService");
        return ygService;
    }

    public static GsjgService createGsjgService() {
        if (gsjgService == null)
            gsjgService = (GsjgService) getAc().getBean("gsjgService");
        return gsjgService;
    }

    public static XyService createXyService() {
        if (xyService == null)
            xyService = (XyService) getAc().getBean("xyService");
        return xyService;
    }

    public static CghtService createCghtService() {
        if (cghtService == null)
            cghtService = (CghtService) getAc().getBean("cghtService");
        return cghtService;
    }

    public static XshtService createXshtService() {
        if (xshtService == null)
            xshtService = (XshtService) getAc().getBean("xshtService");
        return xshtService;
    }

    public static WzjhService createWzjhService() {
        if (wzjhService == null)
            wzjhService = (WzjhService) getAc().getBean("wzjhService");
        return wzjhService;
    }

    public static ZjjhService createZjjhService() {
        if (zjjhService == null)
            zjjhService = (ZjjhService) getAc().getBean("zjjhService");
        return zjjhService;
    }

    public static JkdService createJkdService() {
        if (jkdService == null)
            jkdService = (JkdService) getAc().getBean("jkdService");
        return jkdService;
    }

    public static LjwhService createLjwhService() {
        if (ljwhService == null)
            ljwhService = (LjwhService) getAc().getBean("ljwhService");
        return ljwhService;
    }

    public static QyjgService createQyjgService() {
        if (qyjgService == null)
            qyjgService = (QyjgService) getAc().getBean("qyjgService");
        return qyjgService;
    }

    public static LjLsService createLjLsService() {
        if (ljLsService == null)
            ljLsService = (LjLsService) getAc().getBean("ljLsService");
        return ljLsService;
    }

    public static FkshService createFkshService() {
        if (fkshService == null)
            fkshService = (FkshService) getAc().getBean("fkshService");
        return fkshService;
    }

    public static TpfkService createTPFkshService() {
        if (tpfkService == null)
            tpfkService = (TpfkService) getAc().getBean("tpfkService");
        return tpfkService;
    }

    public static ZjbcdService createZjbcdService() {
        if (zjbcdService == null)
            zjbcdService = (ZjbcdService) getAc().getBean("zjbcdService");
        return zjbcdService;
    }

    public static DoBgcgdSync createDoBgcgdSync() {
        if (doBgcgdSync == null)
            doBgcgdSync = (DoBgcgdSync) getAc().getBean("doBgcgdSync");
        return doBgcgdSync;
    }

    public static Object getBean(String name) {
        return getAc().getBean(name);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.ac = applicationContext;
    }

    public static ApplicationContext getAc() {
        return ac;
    }
}
